#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; gui for menu



GUI() {
    ; suggest should be called as a third-party script
    /*
        Run(A_ScriptDir "/THIRD.ahk gui")
    */

    Sys_IME()   ; Switch the input method



    MENU, menu_all, ADD  ; split symbol
    MENU, menu_all, DeleteAll  ; clear menu item for cache

    MENU, menu_all, ADD
    MENU, menu_all, ADD,  CLOSE &``,  label_do_none



    MENU, menu_all, ADD,  &Q    〇```````n?`n```````n,                     label_code
        MENU, menu_code, ADD,  &b    〇``````bat`n?`n```````n,                     label_code
        MENU, menu_code, ADD,  &c    〇``````cpp`n?`n```````n,                     label_code
        MENU, menu_code, ADD,  &j    〇``````java`n?`n```````n,                    label_code
        MENU, menu_code, ADD,  &h    〇``````html`n?`n```````n,                    label_code
        MENU, menu_code, ADD,  &v    〇``````javascript`n?`n```````n,              label_code
    MENU, menu_all, ADD,  &CodeBlock,                               :menu_code


    MENU, menu_all, ADD  ; menu item end

    MENU, TRAY, ICON, % A_ScriptDir "\res\icon\lion-dance.png"
    MENU, menu_all, SHOW     ; menu show
    ; GUI, +AlwaysOnTop +LastFound +Owner -Caption
    GUI, DESTROY            ; menu destroy
}



GUI_RE() {
    MENU, menu_all, ADD  ; split symbol
    MENU, menu_all, DeleteAll  ; clear menu item for cache

    MENU, menu_all, ADD
    MENU, menu_all, ADD,  CLOSE &``,  label_do_none


    MENU, menu_all, ADD  ; menu item end

    MENU, TRAY, ICON, % A_ScriptDir "\res\icon\lion-dance.png"
    MENU, menu_all, SHOW     ; menu show
    ; GUI, +AlwaysOnTop +LastFound +Owner -Caption
    GUI, DESTROY            ; menu destroy
}



label_do_none:
Return



get_item(item) {
    item := R(item, "^.*?〇", "")
    If(S_Find(item, "〇") ==0){
        Return item
    }
    Return S_Split(item, "〇")
}



label_code:
    v := R_MD(C())
    P(S_Replace(get_item(A_ThisMenuItem), "?", v))
Return



label_met_arr:
    ar := S_Split(get_item(A_ThisMenuItem), "〇")
    ; Method_AR(ar[1], A_Sub(ar, 2, ar.Length()))
Return